/*     */ package com.qmsk.business.area.province.controller;
/*     */ 
/*     */ import com.qmsk.business.area.province.dao.ProvinceDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/province"})
/*     */ public class ProvinceController
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(ProvinceController.class);
/*     */ 
/*     */   @Autowired
/*     */   private ProvinceDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  47 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  49 */       GsonEbRst gsonEbRst = this.dao.getGsonAll(nPageIdx, nPageSize);
/*  50 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  52 */       logger.error(e);
/*  53 */       ResponseUtils.setErrorMsgResponse(
/*  54 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/regionId/{regionId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAllOfRegionId(HttpServletRequest request, @PathVariable("regionId") Integer regionId, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  72 */       GsonEbRst gsonEbRst = this.dao.getGsonAllOfPId(regionId);
/*  73 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  75 */       logger.error(e);
/*  76 */       ResponseUtils.setErrorMsgResponse(
/*  77 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/cityId/{cityId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getId(HttpServletRequest request, @PathVariable("cityId") Integer cityId, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  96 */       GsonEbRst gsonEbRst = this.dao.getID(cityId);
/*  97 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  99 */       logger.error(e);
/* 100 */       ResponseUtils.setErrorMsgResponse(
/* 101 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/regionId/{regionId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListPageOfRegionId(HttpServletRequest request, HttpServletResponse response, @PathVariable("regionId") Integer regionId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 120 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 122 */       GsonEbRst gsonEbRst = this.dao.getGsonPageOfPId(regionId, nPageIdx, nPageSize);
/* 123 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 125 */       logger.error(e);
/* 126 */       ResponseUtils.setErrorMsgResponse(
/* 127 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 143 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 145 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/* 146 */       DbConnection.commit();
/* 147 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 148 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 149 */         response);
/*     */     } catch (Exception e) {
/* 151 */       DbConnection.rollback();
/* 152 */       logger.error(e);
/* 153 */       ResponseUtils.setErrorMsgResponse("插入国家出错:" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 169 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 171 */       String[] strParams = id.split(",");
/* 172 */       int nResult = this.dao.deleteParams(strParams);
/* 173 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 174 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 175 */         response);
/* 176 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 178 */       DbConnection.rollback();
/* 179 */       logger.error(e);
/* 180 */       ResponseUtils.setErrorMsgResponse(
/* 181 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 182 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 198 */     String id = request.getParameter("id");
/* 199 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 201 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 202 */       if (g == null) {
/* 203 */         ResponseUtils.setErrorMsgResponse(
/* 204 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 205 */           response);
/*     */       } else {
/* 207 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 208 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 209 */           RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 210 */           response);
/*     */       }
/* 212 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 214 */       DbConnection.rollback();
/* 215 */       logger.error(e);
/* 216 */       ResponseUtils.setErrorMsgResponse(
/* 217 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 218 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.area.province.controller.ProvinceController
 * JD-Core Version:    0.5.3
 */